package com.jusz.ddns.server.utils;

import org.springframework.util.Assert;

/**
 * @author: tcm
 * @date: 2021/8/25
 * @description ..
 */
public class ApiException extends RuntimeException {
    private static final long serialVersionUID = -4860392988999665699L;
    private int code;
    private String message;
    private boolean isCodeToHttp;

    public int getCode() {
        return this.code;
    }

    public String getMessage() {
        return this.message;
    }

    public boolean isCodeToHttp() {
        return this.isCodeToHttp;
    }

    public ApiException(int code, String message, Throwable throwable) {
        super(ApiException.class.getCanonicalName().concat(":").concat(String.valueOf(code)).concat(":").concat(message), throwable);
        Assert.notNull(message, "The ApiException's message should not be null");
        this.code = code;
        this.message = message;
    }

    public ApiException(int code, String message) {
        this(code, message, (Throwable)null);
    }

    public ApiException(int code, String message, Throwable throwable, boolean isCodeToHttp) {
        super(ApiException.class.getCanonicalName().concat(":").concat(String.valueOf(code)).concat(":").concat(message), throwable);
        Assert.notNull(message, "The ApiException's message should not be null");
        this.code = code;
        this.message = message;
        this.isCodeToHttp = isCodeToHttp;
    }
}
